package com.wwwarehouse.contract.orders.place_order;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.wwwarehouse.common.bean.response.CardDeskFunctionResponseBean;
import com.wwwarehouse.common.bean.response.CommonClass;
import com.wwwarehouse.common.constant.Constant;
import com.wwwarehouse.common.eventbus_event.CardDeskEvent;
import com.wwwarehouse.common.tools.rsa.StringUtils;
import com.wwwarehouse.contract.contract.TheParentFragment;
import com.wwwarehouse.contract.core.ContractConstant;

import contract.wwwarehouse.com.contract.R;
import de.greenrobot.event.EventBus;

/**
 * Created by feng.gao on 2017/10/20.
 * 下单完成页面
 */

public class PlaceOrderSuccessFragment extends TheParentFragment {
	private TextView mNumTv;
	private String demanId;

	@Override
	protected int getContentId() {
		return R.layout.contract_place_order_success_fragment;
	}

	@Override
	protected void init(View view) {
		mNumTv = (TextView) view.findViewById(R.id.num_tv);
		if (getArguments() != null) {
			mNumTv.setText("本次订购" + getArguments().getInt("kind") + "种商品共" + getArguments().getInt("count")+"件\n已为您通知供应商尽快发货");
			if (StringUtils.isNoneNullString(getArguments().getString(ContractConstant.KEY_CONSTRACT_PLACE_ORDER_DEMANID))) {
				demanId = getArguments().getString(ContractConstant.KEY_CONSTRACT_PLACE_ORDER_DEMANID);
			}
		}
		view.findViewById(R.id.place_order_btn).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				//跳到小胖的浏览商品页面
				Bundle bundle = new Bundle();
				CardDeskFunctionResponseBean.TaskBean taskBean = new CardDeskFunctionResponseBean.TaskBean();
				taskBean.setBusinessId(demanId);
				bundle.putSerializable(Constant.KEY_CARD_DESK_FUNCTION_DETAILS , taskBean);
				PlaceOrdersBrowseGoodsPagerFragment placeOrdersBrowseGoodsPagerFragment = new PlaceOrdersBrowseGoodsPagerFragment();
				placeOrdersBrowseGoodsPagerFragment.setArguments(bundle);
				EventBus.getDefault().post(new CardDeskEvent("clear_back_stack"));
				pushFragment(placeOrdersBrowseGoodsPagerFragment);


			}
		});
		view.findViewById(R.id.confirm_btn).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				EventBus.getDefault().post(new CardDeskEvent("clear_back_stack"));
			}
		});

	}

	@Override
	public void setTitle() {
		if (peekFragment() instanceof PlaceOrderSuccessFragment) {
			mActivity.setTitle(R.string.place_order_success);
		}
	}

	@Override
	public void requestDatas() {

	}

	@Override
	public void onSuccess(CommonClass commonClass, int what) {

	}

	@Override
	public void onReLoad(int code) {

	}
}
